package dk.dashboardFP.uiElements {
	import dk.dashboardFP.interactionElementFramwork.smartButton.SmartButton;

	import com.gskinner.motion.GTweener;

	import flash.display.MovieClip;
	import flash.events.Event;

	/**
	 * @author josef
	 */
	public class TitleBarButton extends SmartButton {
		private var _asset : TitleBarButtonAsset;
		private var _eventType : String;
		private var _assetIndex : int;
		private var _back : MovieClip;

		public function TitleBarButton(assetIndex:int, eventType:String) {
		
			_assetIndex = assetIndex;
			_eventType = eventType;
		
			super();
			
			setupElements();
		}

		private function setupElements() : void {
			
			//:::::::
			// asset
			_asset=new TitleBarButtonAsset();
			addChild(_asset);
			
			_asset.gotoAndStop(_assetIndex);
			
			_back = _asset.mcBack;
			_back.alpha=0;
		}

		override protected function get_oClickEvent() : Event {
			return new TitleBarButtonEvent(_eventType);
		}

		override public function mouseOver() : void {
			super.mouseOver();
			GTweener.removeTweens(_back);
			GTweener.to(_back, 0.2, {alpha:1});
 		}

		override public function mouseOut() : void {
			super.mouseOut();
			GTweener.removeTweens(_back);
			GTweener.to(_back, 0.2, {alpha:0});
		}
	}
}
